package com.wangsd.web.api;


import com.wangsd.common.basicbean.Result;
import com.wangsd.web.face.entity.AppVersion;
import com.wangsd.web.face.service.AppVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "App version", tags = "APP版本")
@RestController
@RequestMapping("/api/version")
@Slf4j
public class ApiVersionController {

    @Autowired
    AppVersionService appVersionService;

    @ApiOperation(value = "客户端当前版本号", notes = "客户端当前版本号", httpMethod = "POST")
    @PostMapping("/newest")
    public Result newest(String versionNo) {
        if (StringUtils.isBlank(versionNo)) {
            return Result.fail("获取当前版本号异常");
        }
        AppVersion appVersion = appVersionService.selectNewest(versionNo);
        return Result.success(appVersion);
    }
}
